package com.hongsheng.util;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


public class DriverSqlProvider {
    public static String getUsersByCondition(@Param("driverName") String driverName,
                                      @Param("type") String type,
                                      @Param("status") Integer status) {
        return new SQL() {{
            SELECT("*");
            FROM("tb_driver");
            if (driverName != null && !driverName.isEmpty()) {
                WHERE("driver_name like #{driverName}");
            }
            if (type != null && !type.isEmpty()) {
                WHERE("type = #{type}");
            }
            if (status != null) {
                WHERE("status = #{status}");
            }
        }}.toString();
    }
}
